#ifndef _EngineOS_h_
#define _EngineOS_h_

#ifdef _WIN32
	#include <windows.h>
#endif

typedef struct
{
	int iStackSize;
	int iDetachState;
} ThreadAttr;

typedef unsigned long (__stdcall * THREADFUNC)(void* pvArgs);

#ifdef _WIN32
	#define Library_Handle HINSTANCE
	#define Library_Load(a) LoadLibraryEx(a, NULL, LOAD_WITH_ALTERED_SEARCH_PATH )
	#define Library_GetProc(a, b) GetProcAddress(a, b)
	#define Library_Unload(a) FreeLibrary(a)

	#define Thread_Create(a, b, c, d) \
		HANDLE hHandle = 0; \
		if (b != NULL) \
		{ \
			hHandle = (HANDLE)_beginthreadex(NULL, b->iStackSize, c, d, 0, a); \
		} \
		else \
		{ \
			hHandle = (HANDLE)_beginthreadex(NULL, 0, c, d, 0, a); \
		} \
		return hHandle > 0 ? 0 : GetLastError(); \
		
#endif

#endif